package com.simon.train.business.controller.admin;


import com.simon.train.business.dto.DailyTrainStationQueryDto;
import com.simon.train.business.dto.DailyTrainStationSaveDto;
import com.simon.train.business.service.DailyTrainStationService;
import com.simon.train.business.vo.DailyTrainStationQueryVO;
import com.simon.train.common.Result.Result;
import com.simon.train.common.vo.PageVO;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/dailyTrainStation")
public class DailyTrainStationAdminController {

    @Resource
    private DailyTrainStationService dailyTrainStationService;

    @PostMapping("/save")
    public Result<Object> SaveDailyTrainStation(@Valid @RequestBody DailyTrainStationSaveDto dailyTrainStationSaveDto){
        dailyTrainStationService.SaveDailyTrainStation(dailyTrainStationSaveDto);
        return new Result<>();
    }

    @GetMapping("/queryList")
    public Result<PageVO<DailyTrainStationQueryVO>> DailyTrainStationQueryList(@Valid DailyTrainStationQueryDto dailyTrainStationQueryDto){
         /**
         * businessId通过线程变量获取 从而不需要由前端传入 保证了效率和安全性
         */
        PageVO<DailyTrainStationQueryVO> lists = dailyTrainStationService.QueryDailyTrainStationList(dailyTrainStationQueryDto);
        return new Result<>(lists);
    }

    @DeleteMapping("/delete/{id}")
    public Result<Object> DeleteDailyTrainStation(@PathVariable("id") Long id){
        dailyTrainStationService.deleteDailyTrainStation(id);
        return new Result<>();
    }

}
